<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<jsp:include page="frame/header.jsp"></jsp:include>

<title>房屋信息分类</title>
</head>

<body>

	<div class="container-fluid">
		<div id="market" class="row-fluid">
			<div>
				<ul class="breadcrumb">
					<li><a href="#">实用功能</a> <span class="divider">/</span></li>
					<li><a href="#">房屋信息分类</a></li>
				</ul>
			</div>

			<div class="box">
				<div class="box-header well" data-original-title>
					<h2>
						<i class="icon-th"></i> 房屋出租分类
					</h2>

					<div class="box-icon">
						<a href="#" class="btn btn-setting btn-round"><i
							class="icon-cog"></i></a> <a href="#"
							class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
						<a href="#" class="btn btn-close btn-round"><i
							class="icon-remove"></i></a>
					</div>
				</div>
				<div class="box-content">
					<div id="search-form">
						<form class="form-search span6">
							<input type="text" id="searchText"
								class="input-xlarge search-query">
							<button type="button" id="searchBtn" class="btn">&nbsp;&nbsp;搜索&nbsp;&nbsp;</button>
						</form>
						<div class="span6 text-right">
							<button id="newBtn" class="btn btn-primary">添加新分类</button>
						</div>
					</div>
					<table id="userInfo" class="table table-striped table-bordered ">
						<thead>
							<tr>
								<th>序号</th>
								<th>分类名称</th>
								<th>链接</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<td>1</td>
								<td></td>
								<td>英格兰超级联赛</td>
								
								<td>富勒姆 ~ 埃弗顿 </td>
								<td>某某体育场</td>
								<td>2009-09-13</td>
								<td>22:00:00</td>
								<td><a href="javascript:edit({{userId}})"><i
										class="icon-edit"></i></a> &nbsp;&nbsp; <a
									href="javascript:del({{userId}})"><i class="icon-minus"></i></a></td>
							</tr>
							<tr>
								<td>2</td>
								<td>足球</td>
								<td>英格兰超级联赛</td>
								
								<td>富勒姆 ~ 埃弗顿 </td>
								<td>某某体育场</td>
								<td>2009-09-13</td>
								<td>22:00:00</td>
								<td><a href="javascript:edit({{userId}})"><i
										class="icon-edit"></i></a> &nbsp;&nbsp; <a
									href="javascript:del({{userId}})"><i class="icon-minus"></i></a></td>
							</tr>
							<tr>
								<td>3</td>
								<td>足球</td>
								<td>英格兰超级联赛</td>
								
								<td> 埃弗顿 ~ 布莱克本  </td>
								<td>某某体育场</td>
								<td>2009-09-19 </td>
								<td>21:30:00</td>
								<td><a href="javascript:edit({{userId}})"><i
										class="icon-edit"></i></a> &nbsp;&nbsp; <a
									href="javascript:del({{userId}})"><i class="icon-minus"></i></a></td>
							</tr>
						</tbody>
					</table>
					<div id="mypager" class="mypager"></div>
				</div>
			</div>
		</div>
		<!--/fluid-row-->

	</div>
	<!--/.fluid-container-->

	<jsp:include page="frame/scripts.jsp"></jsp:include>
	<script type="text/javascript">
	
	var userInfo = Tempo.prepare("userInfo");//用户信息
	var curPage = 1;//当前页
	var search = '';//搜索串
	
	$(document).ready(function(){
		
		//加载信息列表
		loadPages(curPage);
		
		$("#newBtn").click(function(){
			//跳转至新增页面
			window.location.href = '<c:url value="/admin/addBall" />';
		})
		
	})
	
	function loadPages(currentPage){
		$.ajax({
			url:'users/pagelist',
			dataType:'json',
			data:{pageNum:currentPage,search:$("#searchText").val()},
			success:function(data){
				curPage = data.pageNum;
				userInfo.render(data.result);
				if(data.totalPage <= 1){
					$("#mypager").hide();
				}else{
					$("#mypager").show();
				}
				$('#mypager').bootstrapPaginator({
					currentPage:data.pageNum,
					totalPages:data.totalPage,
					numberOfPages:data.numPerPage,
					onPageChanged:function(event,oldPage,newPage){
						loadPages(newPage);
					}
				});
			}
		})
	}
	
	function del(id){
		if(confirm("Are you sure you want to destroy it?")){
			$.ajax({
				url:'<c:url value="/admin/user/del/'+id+'" />',
				dataType:'json',
				data:{pageNum:curPage},
				success:function(data){
					userInfo.render(data.result);
					refreshPages(data);
				}
			})
		}
	}
	
	function refreshPages(data){
		if(data.totalPage == 1){
			$("#mypager").hide();
		}
		$('#mypager').bootstrapPaginator({
			currentPage:data.pageNum,
			totalPages:data.totalPage,
			numberOfPages:data.numPerPage
		});
	}
	</script>
</body>
</html>
